import java.util.ArrayList;
import java.util.List;

/**
 * @author wtcode
 * @date 2021/4/19 - 21:45
 */
public class subset2 {
    ArrayList<List<Integer>> res = new ArrayList<>();
    public List<List<Integer>> subsetsWithDup(int[] nums) {

        backtrack(nums,0,new ArrayList<Integer>());
        return res;

    }

    public void backtrack(int[] nums , int start, List<Integer> track){
        res.add(new ArrayList<Integer>(track));
        for(int i = start;i < nums.length ; i++){
            track.add(nums[i]);
            backtrack(nums,i+1,track);
            track.remove(track.size()-1);
        }
    }


}
